package com.dragon.mmochat.message;

import java.util.List;

import com.dragon.mmochat.MmochatConstant;
import com.dragon.mmochat.model.MmochatFileVersion;
import com.dragon.mmochat.model.enumType.MmochatWorkStationType;
import com.skymobi.buffer.Charset;
import com.skymobi.buffer.SkymobiBuffer;
import com.skymobi.message.SkymobiProtocolMessage;

public class Mmochat_1_18S extends SkymobiProtocolMessage {
	List<MmochatFileVersion> needUpdateFiles;

	public Mmochat_1_18S() {
		setMsgCode(MmochatConstant.MSGCODE_MMOCHAT_S_1_18);
	}

	@Override
	protected void encodeBody(SkymobiBuffer out) {
		if (MmochatConstant.workStation == MmochatWorkStationType.青龙自测) {
			out.putInt(MmochatConstant.dragon_downloadModInstance);
		} else if (MmochatConstant.workStation == MmochatWorkStationType.斯凯测试) {
			out.putInt(MmochatConstant.test_downloadModInstance);
		} else {
			out.putInt(MmochatConstant.out_downloadModInstance);
		}
		if (needUpdateFiles == null || needUpdateFiles.size() == 0) {
			out.putInt(0);
		} else {
			out.putInt(needUpdateFiles.size());
			for (MmochatFileVersion file : needUpdateFiles) {
				out.putPrefixedString(file.getFileName(), 1, Charset.US_ASCII);
				out.putInt(file.getSubPackNum());
			}
		}
	}

	public void setNeedUpdateFiles(List<MmochatFileVersion> needUpdateFiles) {
		this.needUpdateFiles = needUpdateFiles;
	}

}